<template>
  <div>
    <!-- 推荐歌单 -->
    <div class="remLists">
      <div class="title" @click="homePage">
        <span class="iconfont icon-xiangzuo"></span> 推荐歌单
      </div>
      <div class="content">
        <ul>
          <li v-for="(item, index) in Personalizedr" :key="index">
            <router-link class="img" :to="'/ranking/rankinglist?id=' + item.id">
              <img :src="item.picUrl" />
            </router-link>
            <p>{{ item.name }}</p>
            <span
              ><i class="iconfont icon-erji"></i
              >{{ item.playCount | playCountData }}</span
            >
          </li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import { getPersonalizedr } from "../../api/recommend";
export default {
  data() {
    return {
      Personalizedr: null,
      imgs: null,
    };
  },
  methods: {
    getPersonalizedrFun() {
      getPersonalizedr().then((data) => {
        console.log(data);
        this.Personalizedr = data.result;
      });
    },
    homePage() {
      this.$router.push("/recommend");
    },
  },
  created() {
    this.getPersonalizedrFun(); //获取推荐歌单
  },
  // 过滤器
  filters: {
    playCountData(value) {
      let w = value > 10000 ? value / 10000 : value; // 万计算
      let y = w > 10000 ? parseInt(value / 10000) + "亿" : parseInt(w) + "万"; //亿计算
      return y;
    },
  },
};
</script>
<style lang="less">
.remLists {
  .title {
    height: 40px;
    line-height: 40px;
    text-indent: 5px;
    font-size: 16px;
    color: white;
    font-weight: 500;
    background-color: #d44439;
  }
  .content {
    ul {
      display: flex;
      flex-wrap: wrap;
      justify-content: space-around;
      li {
        flex: 0 0 32%;
        position: relative;
        span {
          position: absolute;
          top: 0px;
          right: 0px;
          color: #fff;
          font-size: 10px;
          i {
            font-size: 15px;
            vertical-align: middle;
          }
        }
        .img {
          background-color: aqua;
          min-height: 50px;
          width: 100%;
          border-radius: 3px;
          img {
            width: 100%;
            border-radius: 3px;
          }
        }
        p {
          font-size: 12px;
          color: #565658;
          line-height: 15px;
          padding: 5px;
          margin-bottom: 10px;
          height: 26px;
          overflow: hidden;
        }
      }
    }
  }
}
</style>